	//부킹탭
	function clsMyBookingInfo_Tab(){
		this.listData = null;
		this._HTMLDom = null;
		this._init();
	}
	
	clsMyBookingInfo_Tab.prototype = {
		_init: function(){
			var $layer = $("section#my_booking_info section div.tab_menu ul li");			      
			this._HTMLDom = {
				"$layer": $layer	
			}
			$layer.removeClass("on1 on2 on3").eq(0).addClass("on1");	
			$layer.eq(1).hide();
		}	
		, $getBtnTab: function(){
			return this._HTMLDom["$layer"];	
		}
	}
	
	//부킹요약
	function clsMyBookingInfo_Info(){
		this.listData = null;
		this._HTMLDom = null;
		this._init();	
	}
	
	clsMyBookingInfo_Info.prototype = {
		_init: function(){
			var $layer = $("section#my_booking_info section div.bo_table table tbody tr");
			this._HTMLDom = {
				"$layer": $layer	
			}
			$layer.find("td").html(0);
			
			//웨이팅예약 숨김
			$layer.parent().prev().find("tr th:eq(2)").hide();			
			$layer.find("td").eq(2).hide();
		}
		, setReserveConfirm: function(val){
			//예약완료			
			this._HTMLDom["$layer"].find("td:eq(0)").html(val)
		}
		, setPaymentWait: function(val){
			//보증결제대기
			this._HTMLDom["$layer"].find("td:eq(1)").html(val)
		}
		, setWaiting: function(val){
			//웨이팅예약
			this._HTMLDom["$layer"].find("td:eq(2)").html(val)
		}
		, setDonation: function(val){
			//자선예약
			this._HTMLDom["$layer"].find("td:eq(3)").html(val)
		}
	}
	
	//부킹목록
	function clsMyBookingInfo_List(){
		this.listData = null;
		this._HTMLDom = null;
		this._init();
	}
	
	clsMyBookingInfo_List.prototype = {
		_init: function(){
			var $layer = $("section#my_booking_info section>ul.room_list");
			this._HTMLDom = {
				"$layer": $layer	
				, "$element": $layer.find(">li:first")
			}
			
			$layer.empty();
		}
		, setList: function(thisData){
			if(!this.listData) this.listData = [];			
			this.push(thisData);
		}
		, push: function(thisData){
			var thisClass = this;
			var $element = this._HTMLDom["$element"];
			var $tmp = [];
		
			for(var i=0;i<thisData.length;++i){
								
				$tmp.push($element.clone(true));
				$tmp[i].find("li.date").html(thisData[i]["예약날짜"] +"&nbsp;"+ thisData[i]["시간"]);
				$tmp[i].find("li.golf_c").html(thisData[i]["골프장명"]+"&nbsp;-&nbsp;"+ thisData[i]["코스명"]);
				$tmp[i].find("li.price span").html("￦"+_util.fNum(thisData[i]["원가"]));
				$tmp[i].find("li.price mark").html("￦"+_util.fNum(thisData[i]["그린피"]));
				$tmp[i].find("li.state span").removeClass("state state_finish state_ing");
				if(thisData[i]["예약상태코드"] == "G" || thisData[i]["예약상태코드"] == "A"){
					//예약완료
					$tmp[i].find("li.state span").addClass("state").html(thisData[i]["예약상태"]);	
				}else if(thisData[i]["예약상태코드"] == "C"){
					//예약취소
					$tmp[i].find("li.state span").addClass("state_finish").html(thisData[i]["예약상태"]);						
				}else if(thisData[i]["예약상태코드"] == "P"){
					//가예약
					$tmp[i].find("li.state span").addClass("state_ing").html(thisData[i]["예약상태"]);
				}
				
				this.listData.push(thisData[i]);
			}
			this.display($tmp);
		}
		, display: function(thisData){
			var $layer = this._HTMLDom["$layer"];
					
			for(var i=0;i<thisData.length;++i){
				$layer.append(thisData[i]);	
			}
		}
		, reset: function(){			
			this.listData = [];			
			this._HTMLDom["$layer"].empty();
		}
		, $getBtnMore: function(){			            
			return $("section#my_booking_info>section div.btn_area div.btn_more");
		}
		, $getLayer: function(){
			return this._HTMLDom["$layer"];	
		}
		, getListCount: function(){
			if(!this.listData) return 0;
			return this.listData.length;
		}
	}
	
	//데이터연동		
	function clsComm_MyBookingInfo(){
		this.reserveList = null;
		this.reserveListRequest = null;
		this.reserveListPageData = null;
		this.bookingReserveConfirm = null;
		this.bookingPaymentWait = null;
		this.bookingWait = null;
		this._init();
	}	
	clsComm_MyBookingInfo.prototype = {
		_init: function(){
			this.reserveListRequest = {
				"페이지": null	
			}
			this.reserveListPageData = {
				"현재페이지": null
				, "전체수": null
				//, "페이지당수": 10
				//, "블럭당페이지": 1
			}
		}
//------------------------ 예약현황------------------------//
		, getReserveList: function(arg){
			var thisClass = this;
			var szPage = this.reserveListRequest["페이지"];
			
			var objJson = new MJson();
        	var cm = new ConnectionManager();

			objJson.putClient("userid", _util.getLogin("아이디"));
        	objJson.putPub("sid", "US001");
        	objJson.putPub("servicename", "getMyReservList");        	
        	objJson.putParameter("listcount", 10);
			objJson.putParameter("currpageno", szPage);
			        
        	cm.requestGet(objJson.getJsonString(), function(ret){
        		thisClass.reserveList = [];	
        		
        		var items = ret["msp"]["contents"]["items"];
				if(items){
					thisClass.reserveListPageData["전체수"] = ret["msp"]["contents"]["@totalcount"];
									
					if(!items.length) items = new Array(items);
					for(var i=0;i<items.length;i++){
						var obj = items[i];
						var reserv_date = _util.nvl(obj["reserv__date"])+"";
						var reserv_time = _util.nvl(obj["reserv__time"])+"";
						
						var objS = {
							"W": "예약 대기"
							, "P": "가예약"
							, "G": "예약완료"
							, "A": "예약완료"
							, "C": "예약취소"
						}
						
						thisClass.reserveList.push({
							"예약코드": _util.nvl(obj["reserv__seq"])
							, "예약날짜": reserv_date.substrEx(0, 4) + "." + reserv_date.substrEx(4, 2) + "." + reserv_date.substrEx(6, 2)
							, "시간": reserv_time.substrEx(0, 2) + ":" + reserv_time.substrEx(2, 2)
							, "지역코드": _util.nvl(obj["region"])
							, "골프장코드": _util.nvl(obj["golfclub__id"])
							, "코스코드": _util.nvl(obj["course__info__id1"])
							, "골프장명": _util.nvl(obj["golfclub__name"])
							, "코스명": _util.nvl(obj["course__info__name1"])
							, "그린피": _util.nvl(obj["greenfee"], _util.nvl(obj["price"], 0))
							, "원가": _util.nvl(obj["price"], 0)
							, "예약상태코드": _util.nvl(obj["reserv__status"])
							, "예약상태": _util.nvl(objS[_util.nvl(obj["reserv__status"])])
						});
					}
				}
				
				$(thisClass).trigger("evtFinishReserveList");
				
			}, function($err) {
				alert($err);
			});
		}
		, getReserveListData: function(){
			return this.reserveList;
		}
		, getReserveListPageData: function(){
			return this.reserveListPageData;
		}
		, setReserveListRequest: function(key, val){
			this.reserveListRequest[key] = val;
		}
		, getReserveListRequest: function(key){
			return this.reserveListRequest[key];
		}
//------------------------ 예약현황------------------------//		
//------------------------ 예약확정------------------------//		 
		, getBookingReserveConfirm: function(){
			var thisClass = this;
						
			var objJson = new MJson();
        	var cm = new ConnectionManager();

			objJson.putClient("userid", _util.getLogin("아이디"));
        	objJson.putPub("sid", "US001");
        	objJson.putPub("servicename", "getMyBookingAcnt");        	
        	
        	cm.requestGet(objJson.getJsonString(), function(ret){
        		
				thisClass.bookingReserveConfirm = ret["msp"]["contents"]["items"];
				
				$(thisClass).trigger("evtFinishBookingReserveConfirm");
				
			}, function($err) {
				alert($err);
			});			
		}
		, getBookingReserveConfirmData: function(){
			return this.bookingReserveConfirm;
		}
//------------------------ 예약확정------------------------//
//------------------------ 보증결제대기------------------------//		
		, getBookingPaymentWait: function(){
			var thisClass = this;
						
			var objJson = new MJson();
        	var cm = new ConnectionManager();

			objJson.putClient("userid", _util.getLogin("아이디"));
        	objJson.putPub("sid", "US001");
        	objJson.putPub("servicename", "getMyBookingGcnt");       
        	
        	cm.requestGet(objJson.getJsonString(), function(ret){
        		
				thisClass.bookingPaymentWait = ret["msp"]["contents"]["items"];	
				
				$(thisClass).trigger("evtFinishtBookingPaymentWait");
				
			}, function($err) {
				alert($err);
			});
		}
		, getBookingPaymentWaitData: function(){
			return this.bookingPaymentWait;
		}
//------------------------ 보증결제대기------------------------//		
//------------------------ 웨이팅------------------------//		
		, getBookingWaiting: function(){
			var thisClass = this;
						
			var objJson = new MJson();
        	var cm = new ConnectionManager();

			objJson.putClient("userid", _util.getLogin("아이디"));
        	objJson.putPub("sid", "US001");
        	objJson.putPub("servicename", "getMyWaitingCnt");        	
        
        	cm.requestGet(objJson.getJsonString(), function(ret){
        	
				thisClass.bookingWait = ret["msp"]["contents"]["items"];			
				
				$(thisClass).trigger("evtFinishtBookingWait");
				
			}, function($err) {
				alert($err);
			});			
		}
		, getBookingWaitingData: function(){
			return this.bookingWait;	
		}
//------------------------ 웨이팅------------------------//		
	}
	
	//컨트롤파일
	function MyBookingInfo(){		
		this.objComm = null;			
		this.objMyBookingInfo_Tab = null;
		this.objMyBookingInfo_Info = null;
		this.objMyBookingInfo_List = null;
	};
	
	MyBookingInfo.prototype = {
	    onPageShow : function() {
	    	/*사용자 로그인체크
	    	if(!common.userCheck()){
	    		alert("로그인 후 사용하시기 바랍니다.");
	    		return;
	    	}
	    	*/	      
	    	$("a").attr("href", "").attr("data-rel", "");	    	
	    	this._init();
	    }
	    , _init: function(){	    	
	    	
			this.objComm = new clsComm_MyBookingInfo();
	      	this.objMyBookingInfo_Tab = new clsMyBookingInfo_Tab();
			this.objMyBookingInfo_Info = new clsMyBookingInfo_Info();
			this.objMyBookingInfo_List = new clsMyBookingInfo_List();
	      	this.getParam();
	     
	     	this._role();
	     	
	      	this._bind();
	      	this._eventFinish();     	
	     }
	     , _start: function(){
	      	
	      	//예약현황 조회
	      	this.objComm.setReserveListRequest("페이지", 1);
	      	this.objComm.getReserveList();
	      	this.spinStart();
	      	
	      	//예약완료 조회
	      	this.objComm.getBookingReserveConfirm();
	      	//보증결제대기 조회
	      	this.objComm.getBookingPaymentWait();
	      	//웨이팅 조회
	      	this.objComm.getBookingWaiting();
	    }
	    , _eventFinish: function(){
	    	var thisClass = this;
	    	
	    	//예약현황 조회 완료 이벤트
		 	$(this.objComm).bind("evtFinishReserveList", function(event){		 				
		 		var thisData = thisClass.objComm.getReserveListData();
		 		var totalCnt = thisClass.objComm.getReserveListPageData();
 		
		 		thisClass.objMyBookingInfo_List.setList(thisData);
		 		thisClass.spinEnd();
		 		
		 		//더보기 버튼 
		 		if(thisClass.objMyBookingInfo_List.getListCount() >= totalCnt["전체수"]) {
		 			thisClass.objMyBookingInfo_List.$getBtnMore().hide();
		 		}else {
		 			thisClass.objMyBookingInfo_List.$getBtnMore().show();
		 		}
		 	});
		 	
		 	//예약완료 조회 이벤트
		 	$(this.objComm).bind("evtFinishBookingReserveConfirm", function(event){
		 		var thisData = thisClass.objComm.getBookingReserveConfirmData();		 		
		 		thisClass.objMyBookingInfo_Info.setReserveConfirm(thisData);
		 	});
		 	
		 	//보증결제대기 조회 이벤트
		 	$(this.objComm).bind("evtFinishtBookingPaymentWait", function(event){
		 		var thisData = thisClass.objComm.getBookingPaymentWaitData();
		 		thisClass.objMyBookingInfo_Info.setPaymentWait(thisData);
		 	});
		 	
		 	//웨이팅 조회 이벤트
		 	$(this.objComm).bind("evtFinishtBookingWait", function(event){
		 		var thisData = thisClass.objComm.getBookingWaitingData();
		 		thisClass.objMyBookingInfo_Info.setWaiting(thisData);
		 	});
	    }
		 , _bind: function(){
		 	var thisClass = this;
		 			 	
		 	//탭클릭
		 	this.objMyBookingInfo_Tab.$getBtnTab().click(function(event){
		 		event.preventDefault();
		 		var n = thisClass.objMyBookingInfo_Tab.$getBtnTab().index($(this));
		 		var _url = "";
		 		switch(n){
		 			case 0 : _url = "booking_info.html"; break;
		 			case 1 : _url = "booking_info_wait.html"; break;
		 			case 2 : _url = "booking_info_donation.html"; break;
		 		}
		 		$.mobile.changePage(_url,"slide",true);	
		 	});
		 	
		 	//상세보기
		 	this.objMyBookingInfo_List.$getLayer().on("click","a",function(event){
		 		event.preventDefault();
		 		var n = thisClass.objMyBookingInfo_List.$getLayer().find("a").index($(this));		 		
		 		
		 		_gf.BOOKING_DATA["bookingview"]["reserv_id"] = thisClass.objMyBookingInfo_List.listData[n]["예약코드"];		 		
            				 		
		 		$.mobile.changePage("../booking/booking_view.html","slide",true);
		 	});
		 	
		 	//더보기
		 	this.objMyBookingInfo_List.$getBtnMore().click(function(event){
		 		var page = thisClass.objComm.getReserveListRequest("페이지");
		 		thisClass.objComm.setReserveListRequest("페이지",(page+1));
		 		thisClass.objComm.getReserveList();
		 		thisClass.spinStart();
		 	});
		 	
		 	//메뉴
		 	$("section#my_booking_info nav ul li a:eq(0)").click(function(event){
		 		event.preventDefault();
		 		thisClass.goNavi();
		 	});
		 	
		 	//알림
		 	$("section#my_booking_info nav ul li:eq(1)").click(function(event){
		 		event.preventDefault();
		 		$.mobile.changePage("../inc/info_booking.html","slide",true);	
		 	});
		 } 
		 , getParam: function(){
	    	
	    }	    
	    , _role: function(){
	    		if(!_util.getLogin("로그인")){
	    			//alert("로그인 후 이용하실 수 있습니다.");		    			
	    			this.goNavi();		
	    			return;    	
	    		}
	    		
    			this._start();	    		
	   }
		, goNavi: function(){
    		$.mobile.changePage("../inc/navi.html","slide",true);
		}
	    , spinStart: function(){		
			$.mobile.showPageLoadingMsg();			
		}
		, spinEnd: function(){			
	 		$.mobile.hidePageLoadingMsg();				
		}
	}
	